/**********************************************************/
/* Goblin Defense - A tower defense game for Wii Homebrew */
/* Copyright (C) 2009 Ricardo Bueno Cordeiro              */
/* Licensed under de GNU General Public License v2.0      */
/*   See license_gplv2.txt for detalis                    */
/**********************************************************/

#include <gccore.h>

#include "pony_normal.h"
#include "../draw.h"
#include "../game.h"
#include "../map.h"
#include "../effect.h"

PonyNormal::PonyNormal(PATH *p) : Pony(p) {
	this->remain = 0;
	this->age = 0;
	this->life = 1;
}

void PonyNormal::draw() {
	Sprite::draw_sprite(this->get_x(), this->get_y(), 30.0, 30.0, sprite_pony);
}

void PonyNormal::update(u32 step) {
	this->remain += step;
	this->age += step;

	this->advance(this->remain / 10);
	this->remain %= 10;
}

int PonyNormal::remove() {
	return this->life == 0;
}

u32 PonyNormal::get_priority() {
	return this->age;
}

f32 PonyNormal::get_radius() {
	return 10.0;
}

void PonyNormal::hit(Game *game, u32 damage, u32 type) {
	if (this->life > damage)
		this->life -= damage;
	else {
		this->life = 0;
		game->get_map()->add_effect(new Effect(this->get_x(), this->get_y(), 30.0, 30.0, 100, sprite_puff));
		game->get_toolbox()->add_gold(10);
	}
}
